class Solution
{
public:
    int countDigits(int num)
    {
        int result;
        int n = num;
        while (n)
        {
            int digit = n % 10;
            n /= 10;
            if (num % digit == 0)
            {
                ++result;
            }
        }
        return result;
    }
};